
'''实现冒泡排序'''
def bubble_sort(alist):
    for j in range(len(alist)-1,0,-1):
        for i in range(j):
            if alist[i]>alist[i+1]:
                alist[i], alist[i+1] = alist[i+1], alist[i]


li = [54,26,93,17,77,31,44,55,20]
bubble_sort(li)
# print(li)


def bubble(alist):
    for j in range(len(alist)-1,0,-1):  # 0取不到
        print(j)
        for i in range(0,j):
            if alist[i]>alist[i+1]:
                alist[i], alist[i + 1] = alist[i + 1], alist[i]
            # print(alist[i+1])


alist = [1,2,3]
bubble(alist)